package com.juneyaoair;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

/**
 * @author 袁闻锴
 * @date 2020/10/30 22:14
 *
 * @EnableDiscoveryClient 可以被Eureka发现 可以被 zookeeper发现 声明当前项目是一个客户端
 *
 * @EnableEurekaClient 可以被Eureka发现 声明当前项目是一个客户端
 *
 * @EnableFeignClients 开启Feign
 *
 * @EnableHystrix 开启Hystrix
 *
 *  @EnableHystrixDashboard 开启断路器监控
 */
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
@EnableHystrix
@EnableHystrixDashboard
public class EurekaClient2Application {

    public static void main(String[] args) {
        SpringApplication.run(EurekaClient2Application.class, args);
    }

    /*
        创建一个RestTemplate,做restful请求
        @LoadBalanced 开启负载均衡
     */
    @Bean
    @LoadBalanced
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }
}
